package com.car.service;
import com.car.dao.DB;
import com.car.entyti.Carpool;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class CarpoolService {

    public List<Carpool> carpoolList(){
//            String id = carpool.getId();

            List<Map<String,Object>> result = DB.executeQuery("select * from t_carpool");

            List<Carpool> carpools = new ArrayList<>();
            if (result != null) {
                Carpool carpool;
                for (Map<String,Object> stringObjectMap : result){
                    carpool = new Carpool();
                    carpool.setId(stringObjectMap.get("id").toString());
                    carpool.setDeptime(stringObjectMap.get("deptime").toString());
                    carpool.setBecity((String) stringObjectMap.get("becity"));
                    carpool.setDecity((String) stringObjectMap.get("decity"));
                    carpool.setCost((String) stringObjectMap.get("cost"));
                    carpool.setMotor_type((String) stringObjectMap.get("motor_type"));
                    carpool.setUsertype((String) stringObjectMap.get("usertype"));

                    carpools.add(carpool);
                }
                return carpools;
            }else {
                return null;
            }

        }

    public List<Map<String, Object>> getfollow() {
        return DB.executeQuery("select * from t_carpool where usertype=\"司机\"");
    }
    }


